package com.itheima.test.testnight;

public class duotai03 {
    public static void main(String[] args) {
        use(new Dog());
        use(new Cat1());
    }
    public static void use(Animal a){
        a.eat();
        if (a instanceof Dog){
            Dog d=(Dog)a;
            d.watchHome();
        }
    }
}
abstract class Animal{
    public abstract void eat();
}
class Dog extends Animal {
    @Override
    public void eat() {
        System.out.println("狗吃骨头");
    }
    public void watchHome(){
        System.out.println("看家");
    }
}
class Cat1 extends Animal{
    @Override
   public void eat() {
        System.out.println("猫吃鱼");
    }
}